package cn.tedu.charging.cost.controller;

import cn.tedu.charging.cost.service.CostService;
import cn.tedu.common.pojo.JsonResult;
import cn.tedu.common.pojo.param.ChargingProcessParam;
import cn.tedu.common.pojo.vo.ChargingProcessVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("/cost")
@RestController
public class CostController {
    @Autowired
    private CostService costService;

    @PostMapping("calculate")
    public JsonResult<ChargingProcessVO> calculateCost(
            @RequestBody ChargingProcessParam chargingProcessParam){
        log.debug("计费入参:{}",chargingProcessParam);
        ChargingProcessVO chargingProcessVO = costService.calculateCost(chargingProcessParam);
        log.debug("计费结果:{}",chargingProcessVO);
        return JsonResult.ok(chargingProcessVO);
    }
}
